define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'dahui/nianyue2/index',
                    add_url: 'dahui/nianyue2/add',
                    edit_url: 'dahui/nianyue2/edit',
                    del_url: 'dahui/nianyue2/del',
                    multi_url: 'dahui/nianyue2/multi',
                    table: 'dahui_nianyue2',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                searchFormVisible: true,
                columns: [
                    [
                        //{checkbox: true},
                        //{field: 'id', title: __('Id')},
                        {field: 'businessnumber', title: __('Businessnumber'), operate:false},
                        {field: 'paymentdate', title: __('Paymentdate'), operate:false},
                        {field: 'payingcompany', title: __('Payingcompany'), operate:false},
                        {field: 'paymentbase', title: __('Paymentbase'), operate:false},
                        {field: 'paymentamount', title: __('Paymentamount'), operate:false},
                        {field: 'earlytransfer', title: __('Earlytransfer'), operate:false, searchList: {"否":__('否'),"是":__('是')}, formatter: Table.api.formatter.normal},
                        {field: 'newjoin_status', title: __('Newjoin_status'), operate:false, searchList: {"办理失败":__('办理失败'),"已办理":__('已办理'),"未办理":__('未办理')}, formatter: Table.api.formatter.status},
                        {field: 'zc_status', title: __('Zc_status'), operate:false, searchList: {"办理失败":__('办理失败'),"已办理":__('已办理'),"未办理":__('未办理')}, formatter: Table.api.formatter.status},
                        {field: 'refundornot', title: __('Refundornot'), operate:false, searchList: {"":__(''),"已退款":__('已退款'),"待退款":__('待退款'),"需退款":__('需退款')}, formatter: Table.api.formatter.normal},
                        {field: 'taobaoname', title: __('Taobaoname'), operate:false},
                        //{field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        //{field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        //{field: 'luruman', title: __('Luruman')},
                        //{field: 'auditman', title: __('Auditman')},
                        //{field: 'opman', title: __('Opman')},
                        //{field: 'delman', title: __('Delman')},
                        //{field: 'dingdan_id', title: __('Dingdan_id')},
                        //{field: 'yewu.id', title: __('Yewu.id')},
                        //{field: 'yewu.businessnumber', title: __('Yewu.businessnumber')},
                        //{field: 'yewu.businesstype', title: __('Yewu.businesstype')},
                        {field: 'yewu.idnumber', title: __('Yewu.idnumber')},
                        {field: 'yewu.paymentnumber', title: __('Yewu.paymentnumber'), operate:false},
                        //{field: 'yewu.create_time', title: __('Yewu.create_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        //{field: 'yewu.update_time', title: __('Yewu.update_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        //{field: 'yewu.luruman', title: __('Yewu.luruman')},
                        //{field: 'yewu.auditman', title: __('Yewu.auditman')},
                        //{field: 'yewu.opman', title: __('Yewu.opman')},
                        //{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                        //
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});